﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace SharpGen.Addin
{
    public partial class OptionsPage : UserControl, EnvDTE.IDTToolsOptionsPage
    {
        public OptionsPage()
        {
            InitializeComponent();
        }

        #region IDTToolsOptionsPage Members

        public void GetProperties(ref object PropertiesObject)
        {
            //throw new NotImplementedException();
        }

        public void OnAfterCreated(EnvDTE.DTE DTEObject)
        {
            if (File.Exists(txtStartupPath.Text))
            {
                openFileDialog1.InitialDirectory = Path.GetDirectoryName(txtStartupPath.Text);
            }
            else
            {
                openFileDialog1.InitialDirectory = Environment.GetFolderPath(System.Environment.SpecialFolder.MyComputer);
            }
            if (File.Exists(txtTemplatePath.Text))
            {
                openFileDialog2.InitialDirectory = Path.GetDirectoryName(txtTemplatePath.Text);
            }
            else
            {
                openFileDialog2.InitialDirectory = Environment.GetFolderPath(System.Environment.SpecialFolder.MyComputer);
            }
        }

        public void OnCancel()
        {
        }

        public void OnHelp()
        {
            //throw new NotImplementedException();
        }

        public void OnOK()
        {
            Properties.Settings.Default.Save();
        }

        #endregion

        private void btnPathBrowse_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                txtStartupPath.Text = openFileDialog1.FileName;
            }
        }

        private void btnTemplateFilePath_Click(object sender, EventArgs e)
        {
            if (openFileDialog2.ShowDialog() == DialogResult.OK)
            {
                txtTemplatePath.Text = openFileDialog2.FileName;
            }
        }
    }
}
